package com.donzell.model.bean;

import java.util.Date;

import javax.servlet.http.HttpSession;

public class UserSession {
	public static final String USER_SESSION = "USER_SESSION";
	
	private String username;
	private User user;
	private Date loginTime;
	private String password;
	
	
	public static void setUserSession(HttpSession httpSession,UserSession userSession){
		httpSession.setAttribute(USER_SESSION, userSession);
	}
	
	public static UserSession getUserSession(HttpSession httpSession){
		return (UserSession)httpSession.getAttribute(USER_SESSION);
	}
	
	public static User getLoginedUser(HttpSession httpSession){
		if(getUserSession(httpSession) != null){
			return (User)getUserSession(httpSession).getUser();
		}
		return null;
	}
	
	public static boolean isUserLogin(HttpSession httpSession){
		return getUserSession(httpSession) != null;
	}
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Date getLoginTime() {
		return loginTime;
	}
	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	
	
}
